import 'package:flutter/material.dart';
import 'package:webview_flutter/webview_flutter.dart';

class WebCusViewPage extends StatefulWidget {
  const WebCusViewPage({super.key});

  @override
  _WebCusViewPageState createState() => _WebCusViewPageState();
}

class _WebCusViewPageState extends State<WebCusViewPage> {
  late WebViewController _controller; // 用于控制 WebView 的对象
  bool _isLoading = true; // 用于控制加载指示器的显示
  late WebViewWidget _webView; // 用于渲染 WebView 的 Widget

  @override
  void initState() {
    super.initState();
    _controller = WebViewController()
      ..setJavaScriptMode(JavaScriptMode.unrestricted)
      ..loadRequest(Uri.parse('https://servehub.aiconn.com/client?k=8162eaea4e4fa01d3ad2777dcc335430&wp=1'));
    _webView = WebViewWidget(controller: _controller); // 使用 WebViewWidget 显示 WebView

  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        toolbarHeight: 40,
        title: const Text("在线客服", style: TextStyle(fontSize: 17)),
      ),
      body: PopScope(
        canPop: false,
        onPopInvokedWithResult: (didPop, result) {
          if (!didPop) {
            Navigator.pop(context);
          }
        },
        child: _webView,
      ),
    );
  }
}
